<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
<ui:composition>
    <h:form rendered="#{userBean.user.role.idRole == 1}">
        <p:messages id="mes" showDetail="true" closable="true"/>
        <h:panelGrid columns="3">
            <p:outputLabel value="Login: "/>
            <p:inputText id="login" required="true" value="#{registerBean.login}">
                <f:ajax event="keyup" execute="@this" render="loginMes"/>
                <f:validator validatorId="validators.LoginValidator"/>
                <f:validateLength minimum="4"/>
            </p:inputText>
            <p:message for="login" id="loginMes" style="color: red"/>

            <p:outputLabel value="Password: "/>
            <p:password id="pass" value="#{registerBean.password}" match="confirmPass" label="Password" required="true">
                <f:validateLength minimum="5"/>
            </p:password>
            <p:message for="pass" id="passMes" style="color: red"/>

            <p:outputLabel value="Confirm password: "/>
            <p:password id="confirmPass" value="#{registerBean.confirmPassword}" label="Confirm password"  required="true">
                <f:validateLength minimum="5"/>
            </p:password>
            <p:message for="confirmPass" id="confirmPassMes" style="color: red"/>

            <p:outputLabel value="Email: "/>
            <p:inputText id="email" value="#{registerBean.email}">
                <f:ajax event="keyup" execute="@this" render="emailMes"/>
                <f:validateRegex pattern=".+@.+\..+"/>
                <f:validator validatorId="validators.EmailValidator"/>
            </p:inputText>
            <p:message for="email" id="emailMes" style="color: red"/>
        </h:panelGrid>
        <p:commandButton value="Sing un" actionListener="#{registerBean.register}" update="mes"/>
    </h:form>

    <h:form rendered="#{userBean.user.role.idRole != 1}">
        #{navigationBean.action('main.xhtml')}
    </h:form>
</ui:composition>
</html>
